package com.lanou.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.bean.Designer;
import com.lanou.mapper.DesignerMapper;
import com.lanou.service.DesignerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/3/13.
 */
@Service
public class DesignerServiceImpl implements DesignerService{

    @Resource
    private DesignerMapper designerMapper;

    /**
     * 徐鸣
     * @param pageNo
     * @param pageSize
     * @param id
     * @return  根据公司id查询所有设计师
     */
    @Override
    public PageInfo<Designer> findDesignerByComId(Integer pageNo, Integer pageSize, String id) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 2 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<Designer> designers = designerMapper.findDesignerByComId(id);
        PageInfo<Designer> pageInfo = new PageInfo<Designer>(designers);
        return pageInfo;
    }

    /**
     * 徐鸣
     * @param pageNo
     * @param pageSize
     * @param teamId
     * @return  根据团队id查询所有设计师
     */
    @Override
    public PageInfo<Designer> findDesignerByTeamId(Integer pageNo, Integer pageSize, Integer teamId) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 2 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<Designer> designerList = designerMapper.findDesignerByTeamId(teamId);
        PageInfo<Designer> designerPageInfo = new PageInfo<Designer>(designerList);
        return designerPageInfo;
    }

    /**
     * 徐鸣
     * @param id
     * @return 设计师所有信息
     */
    @Override
    public Designer findDesignerById(Integer id) {
        return designerMapper.findDesignerById(id);
    }


}
